<template>
  <drawer-panel v-model="dialogVisible" title="新增站点" size="476px">
    <form-panel :ok-click="submitForm">
      <el-row :gutter="15">
        <el-form ref="elForm" :model="queryObj" :rules="rules" size="medium" label-width="125px" label-suffix="：">
          <el-col :span="elColSpan">
            <el-form-item label="所属水库" prop="field101">
              <el-input v-model="queryObj.field101" placeholder="请输入所属水库" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="监测点名称" prop="field102">
              <el-input v-model="queryObj.field102" placeholder="请输入监测点名称" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="监测点编号" prop="field103">
              <el-input v-model="queryObj.field103" placeholder="请输入监测点编号" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="监测点地址" prop="field104">
              <el-input v-model="queryObj.field104" placeholder="请输入监测点地址" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="经度" prop="field105">
              <el-input v-model="queryObj.field105" placeholder="请输入经度" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="纬度" prop="field106">
              <el-input v-model="queryObj.field106" placeholder="请输入纬度" clearable :style="{ width: '100%' }">
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="简介" prop="field107">
              <el-input
                v-model="queryObj.field107"
                type="textarea"
                placeholder="请输入简介"
                :autosize="{ minRows: 4, maxRows: 4 }"
                :style="{ width: '100%' }"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="elColSpan">
            <el-form-item label="站点照片" prop="field109" required>
              <el-upload ref="field109" :file-list="field109fileList" :action="field109Action" list-type="picture-card">
                <i class="el-icon-plus"></i>
              </el-upload>
            </el-form-item>
          </el-col>
        </el-form>
      </el-row>
    </form-panel>
  </drawer-panel>
</template>

<script>
export default {
  name: 'InfoInput',
  data() {
    return {
      dialogVisible: false,
      elColSpan: 24,
      queryObj: {
        field101: undefined,
        field102: undefined,
        field103: undefined,
        field104: undefined,
        field105: undefined,
        field106: undefined,
        field107: undefined,
        field109: undefined
      },
      rules: {
        field101: [
          {
            required: true,
            message: '请输入所属水库',
            trigger: 'blur'
          }
        ],
        field102: [
          {
            required: true,
            message: '请输入监测点名称',
            trigger: 'blur'
          }
        ],
        field103: [
          {
            required: true,
            message: '请输入监测点编号',
            trigger: 'blur'
          }
        ],
        field104: [
          {
            required: true,
            message: '请输入监测点地址',
            trigger: 'blur'
          }
        ],
        field105: [
          {
            required: true,
            message: '请输入经度',
            trigger: 'blur'
          }
        ],
        field106: [
          {
            required: true,
            message: '请输入纬度',
            trigger: 'blur'
          }
        ],
        field107: [
          {
            required: true,
            message: '请输入简介',
            trigger: 'blur'
          }
        ]
      },
      field109Action: 'https://jsonplaceholder.typicode.com/posts/',
      field109fileList: []
    }
  },
  methods: {
    open() {
      this.dialogVisible = true
    },
    submitForm() {
      this.$refs.elForm.validate(valid => {
        if (!valid) return
        // TODO 提交表单
      })
    },
    resetForm() {
      this.$refs.elForm.resetFields()
    }
  }
}
</script>

<style scoped></style>
